#coding=utf8
keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
def decode64(input):
    output = ''
    chr1, chr2, chr3 = '','',''
    enc1, enc2, enc3, enc4 = '','','',''
    i = 0
    while i < len(input):
        enc1 = keyStr.index(input[i])
        i += 1
        enc2 = keyStr.index(input[i])
        i += 1
        enc3 = keyStr.index(input[i])
        i += 1
        enc4 = keyStr.index(input[i])
        i += 1
        chr1 = (enc1 << 2) | (enc2 >> 4)
        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2)
        chr3 = ((enc3 & 3) << 6) | enc4
        output += chr(chr1)
        if enc3 != 64:
            output += chr(chr2)
        if enc4 != 64:
            output += chr(chr3)
        chr1, chr2, chr3 = '','',''
        enc1, enc2, enc3, enc4 = '','','',''
    return output